<?
	/**
	 * UCConfActive.php
	 * 激活码配置文件
	 *
	 * Copyright (c) 2010 snda.com - Web Development Center
	 * @author: Gu Shougang <gushougang@snda.com>
	 */
	
	include_once(dirname(__FILE__) . '/UCConfMacro.php');
	
	define('MAX_ACTIVE_CODE_COUNT', 100);
	define('ACTIVE_CODE_CHARACTER', 10);
	define('ACTIVE_CODE_UNACTIVED', 0);
	define('ACTIVE_CODE_ACTIVED', 1);
	define('ACTIVE_CODE_BAD', 2);
	
	if(defined('__UC_ENV') && __UC_ENV == 'DEV')
	{
		define('ACTIVE_CODE_START', 0);
		define('ACTIVE_CODE_END', strtotime('2012-01-01 00:00:00'));
	}
	else if(defined('__UC_ENV') && __UC_ENV == 'TEST')
	{
		define('ACTIVE_CODE_START', 0);
		define('ACTIVE_CODE_END', strtotime('2012-01-01 00:00:00'));
	}
	else
	{
		define('ACTIVE_CODE_START', 0);
		define('ACTIVE_CODE_END', strtotime('2010-06-23 23:59:59'));
	}
	
	function get_active_tt_config($active_code)
	{
		return array(
			'tb_name' => md5('UC_ACTIVE_CODE' . $active_code),
		);
	}
	
	function active2dbconfig()
	{
		if(defined('__UC_ENV') && __UC_ENV == 'DEV')
		{
			$host = '10.129.128.14';
			$port = 3306;
			$username = 'root';
			$password = '123qwe';
			$database = 'd_activecode';
			$table = 't_activecode';
		}
		else if(defined('__UC_ENV') && __UC_ENV == 'TEST')
		{
			$host = '10.10.85.4';
			$port = 8066;
			$username = 'ucdbuser';
			$password = 'sdf2w@!w';
			$database = 'd_activecode';
			$table = 't_activecode';
		}
		else
		{
			$host = '10.150.9.5';
			$port = 8066;
			$username = 'ucdbuser';
			$password = '(qnO-ps:Oi^0F0';
			$database = 'd_activecode';
			$table = 't_activecode';
		}
		
		return array(
			'driver' => 'mysql',
			'host' => $host,
			'port' => $port,
			'username' => $username,
			'password' => $password,
			'database' => $database,
			'table' => $table,
		);
	}
	
	function active_channel($channel)
	{
		$channel = trim($channel);
		switch($channel)
		{
			case 'mimmo':
				return 'VYAF8rA2OGSDOMIMMO';
				break;
			default:
				return '';
				break;
		};
	}
	
	/*
	CREATE DATABASE active_code;
	use active_code;
	CREATE TABLE active_code(
	`active_code` VARCHAR(32) NOT NULL COMMENT '激活码',
	`active_status` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '激活状态,0表示未使用,1表示已经使用过,2表示被手动作废',
	`gen_timestamp` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '生成时间',
	`active_timestamp` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '激活时间',
	`active_uid` VARCHAR(24) NOT NULL COMMENT '使用激活码的用户UID',
	UNIQUE KEY `active_code`(active_code)
	) ENGINE = ‘MyISAM’ DEFAULT CHARSET=utf8;
	
	 */
?>